import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MaterialPptVO, MaterialPptForm, MaterialPptQuery } from '@/api/goods/materialPpt/types';

/**
 * 查询PPT模板列表
 * @param query
 * @returns {*}
 */

export const listMaterialPpt = (query?: MaterialPptQuery): AxiosPromise<MaterialPptVO[]> => {
  return request({
    url: '/order/materialPpt/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询PPT模板详细
 * @param id
 */
export const getMaterialPpt = (id: string | number | string[]): AxiosPromise<MaterialPptVO> => {
  return request({
    url: '/order/materialPpt/' + id,
    method: 'get'
  });
};

/**
 * 查询PPT模板详细
 */
export const getMaterialPptAllList = (): AxiosPromise<MaterialPptVO> => {
  return request({
    url: '/order/materialPpt/allList',
    method: 'get'
  });
};

/**
 * 新增PPT模板
 * @param data
 */
export const addMaterialPpt = (data: MaterialPptForm) => {
  return request({
    url: '/order/materialPpt',
    method: 'post',
    data: data
  });
};

/**
 * 修改PPT模板
 * @param data
 */
export const updateMaterialPpt = (data: MaterialPptForm) => {
  return request({
    url: '/order/materialPpt',
    method: 'put',
    data: data
  });
};

/**
 * 删除PPT模板
 * @param id
 */
export const delMaterialPpt = (id: string | number | Array<string | number>) => {
  return request({
    url: '/order/materialPpt/' + id,
    method: 'delete'
  });
};

/**
 * 状态修改
 * @param materialPptId 客户端id
 * @param status 状态
 */
export function changeStatus(materialPptId: string, status: string) {
  const data = {
    materialPptId,
    status
  };
  return request({
    url: '/order/materialPpt/changeStatus',
    method: 'put',
    data: data
  });
}

export default {
  list:listMaterialPpt,
  get:getMaterialPpt,
  add:addMaterialPpt,
  update:updateMaterialPpt,
  del:delMaterialPpt,
  getMaterialPptAllList:getMaterialPptAllList
}